(function () {
  var supportsOrientationChange = 'onorientationchange' in window ? 'orientationchange' : 'resize';
  //防抖函数
  function debounce(handler, interval) {
    var timer = null;
    handler(); //首次执行
    return function () {
      if (timer != null) clearTimeout(timer);
      timer = setTimeout(handler, interval)
    }
  }
  //具体的处理函数
  function handler() {
    var clientW = window.innerWidth; //获取当前窗口的宽度
    clientW = clientW >= 640 ? 640 : clientW; //限制最大的宽度
    var fz = clientW / 375 * 100;
    var view_width = document.getElementsByTagName('html')[0].getBoundingClientRect().width;
    var _html = document.getElementsByTagName('html')[0];
    // view_width>640?_html.style.fontSize=640/16 +'px':_html.style.fontSize =view_width/16+'px';
    document.documentElement.style.fontSize = fz + "px";
    view_width = view_width > 640 ? 640 / 3.75 : view_width / 3.75;
    // _html.style.fontSize= +'px'  _html.style.fontSize= +'px'
    var sw = view_width / 3.75
    var lw = (fz + sw) / 2/5
    document.documentElement.style.fontSize = lw + "px";
    _html.style.fontSize = lw + 'px'
    console.log("_html.style.fontSize:", view_width, "fz:", lw + "px")
  }
  //监听窗口的缩放事件
  window.addEventListener(supportsOrientationChange, debounce(handler, 300));
})()
